﻿using System;
using RabbitMQ.Client;
using System.Text;

class EmitLog
{
    public static void Main(string[] args) {
        while (true) {
            Console.WriteLine("enter message content[enter 'exits' to exit.]");
            string content = Console.ReadLine();
            if (content == "exits")
                break;
            var factory = new ConnectionFactory() { HostName = "10.10.10.45", UserName = "root", Password = "123123" };
            using (var connection = factory.CreateConnection())
            using (var channel = connection.CreateModel()) {
                channel.ExchangeDeclare(exchange: "logs", type: "fanout");
                var body = Encoding.UTF8.GetBytes(content);
                channel.BasicPublish(exchange: "logs",
                                     routingKey: "",
                                     basicProperties: null,
                                     body: body);
                Console.WriteLine(" [x] Sent {0}", content);
            }
        }
    }

    private static string GetMessage(string[] args) {
        return ((args.Length > 0)
               ? string.Join(" ", args)
               : "info: Hello World!");
    }
}